﻿using System;


namespace BankSystem
{
    public class CreditAccount : Account
    {
        private double creditLimit; //设置最大信用额度

        private double creditAmount
        {
            get
            {
                return creditAmount;
            }
            set
            {
                creditAmount = value;
            }
        }

        public CreditAccount(int id,double initialBalance,double creditLimit):base(id,initialBalance) // 先实例化父类再实例化子类
        {
            this.creditLimit = creditLimit;
        }

        public override void Withdraw(double amount)
        {
            if(amount > Balance + creditLimit)
            {
                throw new InvalidOperationException("金额不足");
            }
            Balance -= amount;

            if(amount > 10000)
            {
                onBigMoneyFetched(new BigMoneyArgs(this, amount)); // 大于一万就激活事件
            }

        }

    }
}
